home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW etc / MPW-PR / Interfaces&Libraries / Interfaces / CIncludes / SIO.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-11-30  |  3.2 KB  |  69 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #    SIO.h
  3. #    Simple Inpue/Output 
  4. #    Apple Copyright 1996
  5. #
  6. #    This library permits users to write SIOW-like applications. Supply your
  7. #    own functions to handle standard input and ouput from C or C++.
  8. #
  9. #-----------------------------------------------------------------------------*/
  10.  
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14.  
  15. enum
  16. {
  17.     kSIOStdOutNum = 1,
  18.     kSIOStdErrNum = 2
  19. };
  20.  
  21. /* If your code has static c++ objects whose constructors invoke i/o, then             */
  22. /* these functions may be invoked before main() is entered.                         */
  23.  
  24. extern pascal void (*__sioInit)( int * mainArgc, char *** mainArgv );
  25.     /* Assign a pointer to your function to the variable __sioInit in order         */
  26.     /* to be able to program initialization before main() begins. This permits         */
  27.     /* calling MacOS initialization functions and setting up windows, arguments     */
  28.     /* to main(), etc.                                                                 */
  29.     /* mainArgc is a pointer to the int argc value passed into main(). You may        */
  30.     /* assign to int values to *mainArgc.                                            */
  31.     /* mainArgv is a pointer to a pointer to an array of char-pointers. You may     */
  32.     /* allocate an array of char-pointers using NewPtr() and assign that to         */
  33.     /* *mainArgv.                                                                    */
  34.  
  35. extern pascal void (*__sioRead)(    char     * buffer, 
  36.                                     SInt32     nCharsDesired, 
  37.                                     SInt32     * nCharsUsed, 
  38.                                     SInt16     * eofFlag );
  39.     /* Assign a pointer to your function to the variable __sioRead in order         */
  40.     /* handle read-requests for stdin.                                                 */
  41.     /* buffer is a character array of size nChars. Your should fill it with         */
  42.     /* characters until the user hit carriage return or enter, or nChars have         */
  43.     /* been gotten.  Carriage return or enter should be represented as the '\n'        */
  44.     /* character (character code == 13 == 0x0d).                                     */
  45.     /* To indicate end of file, you have two options: set *nCharsUsed to zero and     */
  46.     /* *eofFlag to non-zero to immediately signal end of file, OR fill the buffer     */
  47.     /* some number of characters, set *nCharsUsed to that number, set *eofFlag to     */
  48.     /* non-zero: now the next time read() would be invoked, end of file will be     */
  49.     /* indicated and your function will not be called. Once *eofFlag has been         */
  50.     /* set, your function will never be called again.                                 */
  51.     /* You may want to implement an event loop here to catch key-strokes for user-    */
  52.     /* input. Note if your user chooses Quit from the File menu, for example, you    */
  53.     /* should either return end-of-file or call abort() or exit() to properly shut     */
  54.     /* down the application. Calling ExitToShell() will skip calling __sioExit().    */
  55.  
  56. extern pascal void (*__sioWrite)( SInt16 filenum, char * buffer, SInt32 nChars );
  57.     /* Assign a pointer to your function to the variable __sioWrite in order         */
  58.     /* handle write-requests for stdout (filenum == 1) and stderr (filenum == 2).     */
  59.  
  60. extern pascal void (*__sioExit)( void );
  61.     /* This function is called after main() returns, or if exit() is called, or     */
  62.     /* if abort() is called. Note: It is not called if ExitToShell() was called!     */
  63.     /* You may want to implement an event loop here to allow the user to save         */
  64.     /* output.                                                                         */
  65.  
  66. #ifdef __cplusplus
  67. }
  68. #endif
  69.